#coding=utf-8
from orm import Model,IntegerType,CharType,DatetimeType,Key,UniqueKey,build_model
from settings import DEFAULT_USER_DB_NAME

@build_model
class UserLoginInfo(Model):
    _table = 'user_login_info'
    _name = '用户登录信息表'
    _conn_name = 'test_wby'
    id = IntegerType(name='id', comment='主键', length=10, auto_increase=True, primary_key=True, unsigned=True)
    login_name = CharType(name='login_name', comment='登录名', length=20, blank=False)
    nick_name = CharType(name='nick_name', comment='昵称', length=20, blank=False)
    e_mail = CharType(name='e_mail', comment='电子邮件', length=50, blank=True)
    password = CharType(name='password', comment='密码', length=50, blank=False)
    user_status = IntegerType(name='user_status', comment='用户状态', length=3, blank=0, unsigned=True)
    weixin_login_id = IntegerType(name='weixin_login_id', comment='微信登录id', length=11, blank=0, unsigned=True)
    qiuqiu_login_id = IntegerType(name='qiuqiu_login_id', comment='QQ登录id', length=11, blank=0, unsigned=True)
    create_at = DatetimeType(name='create_at', comment='创建时间', auto='on_create')
    update_at = DatetimeType(name='update_at', comment='更新时间', auto='on_update')

@build_model
class UserGroup(Model):
    _table = 'user_group'
    _name = '用户组'
    _conn_name = 'test_wby'
    id = IntegerType(name='id', comment='用户登录表id', length=10, primary_key=True, unsigned=True)
    group_id = IntegerType(name='group_id', comment='用户组id', length=3, blank=0, unsigned=True)
    custom_group_id = IntegerType(name='custom_group_id', comment='定制用户组id', length=8, blank=0, unsigned=True)
    update_at = DatetimeType(name='update_at', comment='更新时间', auto='on_update')

@build_model
class UserInfo(Model):
    _table = 'user_info'
    _name = '用户信息表'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id', comment='用户登录表id', length=10, primary_key=True, unsigned=True)
    user_name = CharType(name='user_name', comment='姓名', length=10, blank=True)
    user_age = IntegerType(name='user_age', comment='年龄', length=3, blank=-1)
    user_sex = CharType(name='user_sex', comment='性别', length=2, blank=True)
    user_corporation = CharType(name='user_corporation', comment='公司', length=255, varchar=True, blank=True)
    user_occupation = CharType(name='user_occupation', comment='职位', length=255, varchar=True, blank=True)
    weixin_num = CharType(name='weixin_num', comment='微信号', length=255, varchar=True, blank=True)
    qiuqiu_num = CharType(name='qiuqiu_num', comment='QQ号', length=255, varchar=True, blank=True)
    e_mail = CharType(name='e_mail', comment='电子邮件', length=50, blank=True)
    cell_phone = CharType(name='cell_phone', comment='手机号码', length=20, blank=True)
    telephone = CharType(name='telephone', comment='固定电话', length=20, blank=True)
    user_fax = CharType(name='user_fax', comment='传真', length=20, blank=True)
    birthday = CharType(name='birthday', comment='生日', length=4, blank=True)
    current_location = CharType(name='current_location', comment='所在地', length=20, blank=True)
    user_avatar = CharType(name='user_avatar', comment='头像url', length=255, varchar=True, blank=True)

@build_model
class UserSubscribe(Model):
    _table = 'user_subscribe'
    _name = '用户订阅'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id', comment='用户登录表id', length=10, primary_key=True, unsigned=True)
    feed_id = IntegerType(name='feed_id', comment='订阅feed的id', length=8, unsigned=True)
    create_at = DatetimeType(name='create_at', comment='创建时间', auto='on_create')

@build_model
class Users(Model):
    _table = 'users'
    _name = '用户基本表'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id',comment='用户id',length=10,primary_key=True,unsigned=True)
    openid = CharType(name='openid',comment='微信开放id',length=100,varchar=True)
    nickname = CharType(name='nickname',comment='昵称',length=255,varchar=True)
    sex = IntegerType(name='sex',comment='性别',blank=0,length=4)
    language = CharType(name='language',comment='语言',length=100,varchar=True)
    city = CharType(name='city',comment='城市',length=100,varchar=True)
    province = CharType(name='province',comment='省',length=100,varchar=True)
    country = CharType(name='country',comment='国家',length=100,varchar=True)
    headimgurl = CharType(name='headimgurl',comment='头像url',length=255,varchar=True)
    unionid = CharType(name='unionid',comment='不知道是什么',length=100,varchar=True)
    is_used = IntegerType(name='is_used',comment='被使用',length=4,blank=0)
    level = IntegerType(name='level',comment='等级',length=4,blank=0)
    user_id = IntegerType(name='user_id', comment='用户id', length=11, unsigned=True)
    created_at = DatetimeType(name='created_at',auto='on_create')
    updated_at = DatetimeType(name='updated_at',auto='on_update')

@build_model
class AuthUsers(Model):
    _table = 'neican_auth_user'
    _name = '内参用户表'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id',comment='用户id',length=11,primary_key=True,unsigned=True,auto_increase=True)
    #password = CharType(name='password',comment='密码',length=128,varchar=True)
    last_login = DatetimeType(name='last_login',comment='上次登录')
    is_superuser = IntegerType(name='is_superuser',comment='是否超级用户',length=1,unsigned=True,blank=0)
    #username = CharType(name='username',comment='用户名',length=150,varchar=True)
    nickname = CharType(name='nickname',comment='昵称',length=50,varchar=True)
    email = CharType(name='email',comment='电子邮件',length=254,varchar=True)
    email_pass = IntegerType(name='email_pass', comment='邮箱验证', length=1, unsigned=True, blank=0)
    logo = CharType(name='logo',comment='头像url',length=255,varchar=True)
    is_staff = IntegerType(name='is_staff',comment='是否职员',length=1,unsigned=True,blank=0)
    is_inited = IntegerType(name='is_inited',comment='是否初始化',length=1,unsigned=True,blank=0)
    is_active = IntegerType(name='is_active',comment='是否激活',length=1,unsigned=True,blank=0)
    date_joined = DatetimeType(name='date_joined',comment='加入时间',auto='on_create')
    key_nickname_index = Key(key_name='key_nickname_index',col_name='nickname')

@build_model
class CellPhoneUsers(Model):
    _table = 'cell_phone_user'
    _name = '手机用户'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id',comment='电话记录id',length=11,primary_key=True,unsigned=True,auto_increase=True)
    phone_num = CharType(name='phone_num',comment='电话号码',length=25,varchar=True)
    password = CharType(name='password',comment='密码',length=128,varchar=True)
    last_login = DatetimeType(name='last_login',comment='上次登录')
    user_id = IntegerType(name='user_id',comment='用户id',length=11,unsigned=True)
    ukey_phone_num_index = UniqueKey(key_name='ukey_phone_num_index',col_name='phone_num')
